package com.qianyu.project.mapper.provider.zy;

import com.qianyu.project.entity.ProjectInfo;
import com.qianyu.project.entity.ProjectStatus;
import jdk.nashorn.internal.objects.annotations.Where;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

public class ZYProjectStatusProvider {
    //ProjectStatus ps
    public String getPStatus(ProjectStatus ps){
        return new SQL(){
            {
                SELECT("*");
                FROM("project_info pi,project_status ps,identify_info ii");
                WHERE("ps.id=pi.id");
                WHERE("ps.tian=ii.id");
                if (!ObjectUtils.isEmpty(ps.getProjectName())){
                    WHERE("pi.project_name like '%"+ps.getProjectName()+"%'");
                }
                if (!ObjectUtils.isEmpty(ps.getName())){
                    WHERE("ii.`name` like '%"+ps.getName()+"%'");
                }
                if (!ObjectUtils.isEmpty(ps.getProjectStatus())){
                    WHERE("pi.project_status='"+ps.getProjectStatus()+"'");
                }

            }
        }.toString();
    }

    //getStatuByid
    public String getStatuByid(String sid){
        return new SQL(){
            {
                SELECT("*");
                FROM("project_info pi,project_status ps,identify_info ii");
                WHERE("ps.id=pi.id");
                WHERE("ps.tian=ii.id");
                WHERE("ps.sid="+sid);

            }
        }.toString();
    }
}
